package com.doushu.dispatch.mapper;

import com.doushu.dispatch.entity.KeywordAnalysis;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface KeywordAnalysisMapper {
//    @Select({
//            "<script>"
//                    + "INSERT INTO ds_keywordanalysis(payAmt,payBuyerCnt,payRate,keyword,uv,payItemQty,bounceRate,pv,avgPv,clickCnt,clickRate,expose,avgSeRank,iid,datatime,terminal,sid) VALUES"
//                    + "<foreach collection='list' item='item' separator=','>"
//                    + "(#{item.payAmt},#{item.payBuyerCnt},#{item.payRate},#{item.keyword},#{item.uv},#{item.payItemQty},#{item.bounceRate},#{item.pv},#{item.avgPv},#{item.clickCnt},#{item.clickRate},#{item.expose},#{item.avgSeRank},#{item.iid},#{item.datatime},#{terminal},#{sid})"
//                    + "</foreach>"
//                    + "</script>"
//    })
//    Integer insertKeywordAnalysises(List<KeywordAnalysis> items);

    @Insert("INSERT INTO ds_keywordanalysis(payAmt,payBuyerCnt,payRate,keyword,uv,payItemQty,bounceRate,pv,avgPv,clickCnt,clickRate,expose,avgSeRank,iid,datatime,terminal,sid) VALUES (#{payAmt},#{payBuyerCnt},#{payRate},#{keyword},#{uv},#{payItemQty},#{bounceRate},#{pv},#{avgPv},#{clickCnt},#{clickRate},#{expose},#{avgSeRank},#{iid},#{datatime},#{terminal},#{sid})")
    Integer insertKeywordAnalysis(KeywordAnalysis item);

    @Select({"SELECT 1 FROM ds_keywordanalysis WHERE sid=#{sid} AND datatime=#{datatime} AND iid=#{iid} LIMIT 1"})
    Boolean existsBySidAndDatatimeAndIid(@Param("sid")Long sid, @Param("datatime")String datatime, @Param("iid")Long iid);
}
